<template>
	<view class="content">
		<view class="block apply-block">
			<block v-if="applyList.length>0">
				<view class="item-block" v-for="(item) in applyList" :key="item.id"
					@click="navigate('/page_other/train/detail?id='+item.id+'&type='+item.trainState)">
					<image :src="item.logo?item.logo:imageUrl+'/job_hunting/job_detail/enterprise.jpg'" class="img">
					</image>
					<view class="top-title">
						<view class="apply-title">{{item.company}}</view>
						<view class="desc">
							<view class="iconfont icon-dingwei"></view>
							<view class="desc-text">{{item.transaddress}}</view>
						</view>
					</view>
				</view>
			</block>
			<view v-else-if="applyList.length==listConf.count&&!listConf.more" style="text-align: center;">没有更多了哦</view>
			<view v-else class="empty">暂无数据</view>
		</view>
	</view>
</template>

<script>
	import {
		getTrainingList,
		getVideoTrainList
	} from '@/api/train.js';
	import {
		getNewsList as getNewsListApi
	} from '@/api/notice.js'
	import {
		isMore
	} from '@/util/util.js'
	export default {
		data() {
			return {
				applyList: [],
				listConf: {
					page: 1,
					limit: 999,
					more: true,
					count: 0
				},
				imageUrl: ''
			}
		},
		methods: {
			getTrainList(refresh = false) {
				getTrainingList({
					page: this.listConf.page,
					limit: this.listConf.limit,
				}).then((res) => {
					let list = res.modelList || [];
					this.applyList = refresh ? list : [...this.applyList, ...list];
					this.listConf.count = res.count
					this.listConf.more = isMore(this.listConf.page, this.listConf.limit, res.count);
				})
			},
			navigate(url) {
				uni.navigateTo({
					url
				})
			},
			play(id) {
				if (this.videoContext && this.videoId != id) {
					this.videoContext && this.videoContext.stop();
				}
				this.videoContext = uni.createVideoContext(id, this);
				this.videoId = id;
			},

		},
		onLoad() {
			this.imageUrl = this.globalConfig.imageUrl;
			this.getTrainList(true);
		},
		onReachBottom() {
			if (this.isMore) {
				this.page++;
				this.getTrainList(true);
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fafafa;
	}

	.content {
		width: 100%;
		padding: 30rpx;

		.block {
			width: 100%;

		}

		.block.apply-block {
			.item-block {
				display: flex;
				align-items: center;
				width: 100%;
				background-color: #fff;
				///box-shadow: 0px 0px 4px #ccc;
				border-radius: 10rpx;
				margin-bottom: 30rpx;
				padding: 25rpx;

				.img {
					width: 150rpx;
					height: 150rpx;
					border-radius: 20rpx;
					margin-right: 20rpx;
				}

				.top-title {
					width: calc(100% - 170rpx);
					display: flex;
					flex-direction: column;
					justify-content: center;

					.apply-title {
						font-weight: bold;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
						margin-bottom: 30rpx;
					}

					.desc {
						display: flex;
						align-items: center;

						.iconfont {
							color: #0256FF;
							margin-right: 10rpx;
						}

						.desc-text {
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
							color: #999;
							font-size: 26rpx;
						}
					}
				}
			}
		}
	}
</style>